<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/util.js"></script>

    <script>
        async function land(){
            var param = {name:$("name").value,pwd:$("pwd").value};
            await axios.get("/user/login",{params:param}).then(e => {
                var info = e.data;
                localStorage.setItem("token",e.headers.token);

                if(info == "ok"){
                    location.href = "/html/index.html";
                }
                else{
                    $("errorDiv").innerHTML = "用户名或密码错误";
                }
            });


        }

        function test(){
            var str = localStorage.getItem("token");
            alert(str);
            axios.get("/user/getLoginUser",{headers:{token:str}}).then(e => {
                info = e;
            });
        }
    </script>
</head>
<body>
    <div id="errorDiv" style="color: red;font-size: 12px"></div>
    用户名pp：<input type="text" id="name"><br>
    密码：<input type="password" id="pwd"><br>
    <input type="button" value="登陆" onclick="land()">
    <input type="button" value="测试" onclick="test()">
</body>
</html>